package com.glorysoft.wangnianxinpda.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.glorysoft.wangnianxinpda.R;
import com.glorysoft.wangnianxinpda.adapter.viewholder.DataBindingBaseViewHolder;
import com.glorysoft.wangnianxinpda.databinding.AdapterMaterialExchangeBinding;
import com.glorysoft.wangnianxinpda.entity.MaterialInfoEntity;

import java.util.List;

/**
 * @Author Zhangjy
 * @Date 2021/6/30 16:24
 * Description :
 */
public class MaterialExchangeAdapter extends BaseQuickAdapter<MaterialInfoEntity, DataBindingBaseViewHolder> {
    public MaterialExchangeInfoAdapter.OnClickListener listener;
    public MaterialExchangeAdapter(int layoutResId, @Nullable List<MaterialInfoEntity> data) {
        super(layoutResId, data);
    }

    public void setListener(MaterialExchangeInfoAdapter.OnClickListener listener) {
        this.listener = listener;
    }

    @Override
    protected void convert(DataBindingBaseViewHolder helper, MaterialInfoEntity item) {
        AdapterMaterialExchangeBinding binding = (AdapterMaterialExchangeBinding) helper.getDataBinding();
        binding.setMaterialInfoEntity(item);
        MaterialExchangeInfoAdapter adapter = new MaterialExchangeInfoAdapter(R.layout.adapter_material_exchange_info,item.getTOOLLIST());
        adapter.setListener(listener);
        adapter.setCode(item.getMATERIALCODE());
        binding.rvMaterialInfo.setAdapter(adapter);
        binding.executePendingBindings();
    }

}
